package mo.tags.greedy;

import java.util.Arrays;
import java.util.Comparator;

public class L646 {

    public int findLongestChain(int[][] pairs) {
        Arrays.sort(pairs, Comparator.comparingInt(p -> p[1]));
        int cur = Integer.MIN_VALUE, res = 0;
        for (int[] p : pairs) {
            if (cur < p[0]) {
                cur = p[1];
                res++;
            }
        }
        return res;
    }

}
